import 'dart:ui';

import 'package:flutter/material.dart';

import 'base/base_effect.dart';
import 'effect_template.dart';

class Effect16 extends EditableAnimationEffect {
  @override
  List<Color> get defaultColors {
    return const [
      Color(0xFF0000FF),
      Color(0xFF00C0FF),
      Color(0xFFFFFFFF),
      Color(0xFF0000FF),
      Color(0xFF00C0FF),
      Color(0xFFFFFFFF)
    ];
  }

  @override
  bool get enableAngle => false;

  @override
  bool get enableColorWidth => true;

  @override
  RangeArgument get colorWidthRange => RangeArgument(3, 24, 3);

  @override
  bool get enableDensity => false;

  @override
  bool get enableEditColor => false;

  @override
  bool get enableSpeed => false;

  @override
  bool get isFixedColorCount => false;

  @override
  RangeArgument get colorCountRange => RangeArgument(1,6,6);

  @override
  EffectType get effectTyp => EffectType.effect16;

  @override
  Future<List<List<List<Color>>>> getFrames({EffectOperation? operation}) {

    List<Color> colorList = getColorList(effectOperation: operation);
    double sizeWidth = size.width;
    double sizeHeight = size.height;
    List<List<List<Color>>> frames = [];
    int colorWidth = operation?.colorWidth ?? colorWidthRange.defaultValue;
    int heightExample = sizeHeight.toInt();
    int totalFrame = sizeHeight.toInt();

    final length = colorList.length;
    List<Color> colorExample = [];
    for (int i = 0; i < length; i++) {
      for (int j = 0; j < colorWidth; j++) {
        colorExample.add(colorList[i]);
      }
    }

    for (int z = 0; z < totalFrame; z++) {
      List<List<Color>> columns = [];
      for (int i = 0; i < sizeWidth; i++) {
        List<Color> rows = [];
        for (int j = 0; j < sizeHeight; j++) {
          Color color =
          colorExample[(heightExample - 1 - j) % colorExample.length];
          rows.add((heightExample - 1 - j) <= z ? color : Colors.transparent);
        }
        columns.add(rows);
      }
      frames.add(columns);
    }
    return Future.value(frames);
  }

  @override
  Size get size => const Size(24, 24);
}